{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from rqdatac import *\n",
    "import rqdatac as rq\n",
    "\n",
    "\n",
    "rq.init('15268829004', '123456')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date\n",
       "2010-04-19    IF1005\n",
       "2010-04-20    IF1005\n",
       "2010-04-21    IF1005\n",
       "2010-04-22    IF1005\n",
       "2010-04-23    IF1005\n",
       "               ...  \n",
       "2021-12-20    IF2201\n",
       "2021-12-21    IF2201\n",
       "2021-12-22    IF2201\n",
       "2021-12-23    IF2201\n",
       "2021-12-24    IF2201\n",
       "Name: dominant, Length: 2843, dtype: object"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# futures.get_dominant('IF', '20160801')\n",
    "futures.get_dominant('IF', end_date='20220501')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date\n",
       "2018-12-11    EG1906\n",
       "2018-12-12    EG1906\n",
       "2018-12-13    EG1906\n",
       "2018-12-14    EG1906\n",
       "2018-12-17    EG1906\n",
       "               ...  \n",
       "2021-12-20    EG2205\n",
       "2021-12-21    EG2205\n",
       "2021-12-22    EG2205\n",
       "2021-12-23    EG2205\n",
       "2021-12-24    EG2205\n",
       "Name: dominant, Length: 739, dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "futures.get_dominant('eg', end_date='20220501')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date\n",
       "2012-12-31    RM1305\n",
       "2013-01-04    RM1305\n",
       "2013-01-07    RM1305\n",
       "2013-01-08    RM1305\n",
       "2013-01-09    RM1305\n",
       "               ...  \n",
       "2021-12-20    RM2205\n",
       "2021-12-21    RM2205\n",
       "2021-12-22    RM2205\n",
       "2021-12-23    RM2205\n",
       "2021-12-24    RM2205\n",
       "Name: dominant, Length: 2184, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "futures.get_dominant('RM', end_date='20220501')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_book_id</th>\n",
       "      <th>symbol</th>\n",
       "      <th>abbrev_symbol</th>\n",
       "      <th>type</th>\n",
       "      <th>listed_date</th>\n",
       "      <th>de_listed_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>C2005C2180</td>\n",
       "      <td>玉米2005购2180</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-05-21</td>\n",
       "      <td>2020-04-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CU2002C49000</td>\n",
       "      <td>铜2002购49000</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-02-18</td>\n",
       "      <td>2020-01-20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>CU2001C51000</td>\n",
       "      <td>铜2001购51000</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-01-16</td>\n",
       "      <td>2019-12-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>M2007P2650</td>\n",
       "      <td>豆粕2007沽2650</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-07-16</td>\n",
       "      <td>2020-06-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CF1909P13000</td>\n",
       "      <td>棉花1909沽13000</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-05-15</td>\n",
       "      <td>2019-08-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62668</th>\n",
       "      <td>688220.XSHG</td>\n",
       "      <td>翱捷科技</td>\n",
       "      <td>AJKJ</td>\n",
       "      <td>CS</td>\n",
       "      <td>2999-12-31</td>\n",
       "      <td>0000-00-00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62669</th>\n",
       "      <td>159831.XSHE</td>\n",
       "      <td>嘉实上海金ETF</td>\n",
       "      <td>JSSHJETF</td>\n",
       "      <td>ETF</td>\n",
       "      <td>2999-12-31</td>\n",
       "      <td>0000-00-00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62670</th>\n",
       "      <td>10003877</td>\n",
       "      <td>50ETF购2月3700</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>2022-02-23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62671</th>\n",
       "      <td>10003878</td>\n",
       "      <td>50ETF沽2月3700</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>2022-02-23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62672</th>\n",
       "      <td>517760.XSHG</td>\n",
       "      <td>浦银消费龙头ETF</td>\n",
       "      <td>PYXFLTETF</td>\n",
       "      <td>ETF</td>\n",
       "      <td>2999-12-31</td>\n",
       "      <td>0000-00-00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>62673 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      order_book_id        symbol abbrev_symbol    type listed_date  \\\n",
       "0        C2005C2180   玉米2005购2180          None  Option  2019-05-21   \n",
       "1      CU2002C49000   铜2002购49000          None  Option  2019-02-18   \n",
       "2      CU2001C51000   铜2001购51000          None  Option  2019-01-16   \n",
       "3        M2007P2650   豆粕2007沽2650          None  Option  2019-07-16   \n",
       "4      CF1909P13000  棉花1909沽13000          None  Option  2019-05-15   \n",
       "...             ...           ...           ...     ...         ...   \n",
       "62668   688220.XSHG          翱捷科技          AJKJ      CS  2999-12-31   \n",
       "62669   159831.XSHE      嘉实上海金ETF      JSSHJETF     ETF  2999-12-31   \n",
       "62670      10003877  50ETF购2月3700          None  Option  2021-12-24   \n",
       "62671      10003878  50ETF沽2月3700          None  Option  2021-12-24   \n",
       "62672   517760.XSHG     浦银消费龙头ETF     PYXFLTETF     ETF  2999-12-31   \n",
       "\n",
       "      de_listed_date  \n",
       "0         2020-04-08  \n",
       "1         2020-01-20  \n",
       "2         2019-12-25  \n",
       "3         2020-06-05  \n",
       "4         2019-08-05  \n",
       "...              ...  \n",
       "62668     0000-00-00  \n",
       "62669     0000-00-00  \n",
       "62670     2022-02-23  \n",
       "62671     2022-02-23  \n",
       "62672     0000-00-00  \n",
       "\n",
       "[62673 rows x 6 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_instruments(type=None, market='cn', date=None)\n",
    "\n",
    "# type : CS\tCommon Stock, 即股票   Future\tFutures，即期货，包含股指、国债和商品期货"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
